<?php namespace app\admin\controller;

use houdunwang\request\Request;
use system\model\Slide as SlideModel;

class Slide extends Common {

	public function __construct()
	{
		$this->auth();
	}

	public function index()
	{
		$field = SlideModel::paginate(1);
		return view('',compact('field'));
    }

    /*
     * 添加，编辑
     */
    public function post()
	{
		$slide_id = Request::get('slide_id');
		$model = SlideModel::find($slide_id) ? : new SlideModel();
		if(IS_POST)
		{
			$model->save(Request::post());
			return $this->setRedirect('index')->success('操作成功');
		}
		return view('',compact('model'));
	}

	/*
	 * 删除
	 */
	public function remove()
	{
		$slide_id = Request::get('slide_id');
		$model = SlideModel::find($slide_id);
		$model->destory();
		return $this->setRedirect('index')->success('操作成功');
	}
}
